package movie.serlvet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import movie.dao.MovieDao;
import movie.dao.impl.MovieDaoImpl;
import movie.entity.Movie;

import com.google.gson.Gson;


public class MovieListServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		MovieDao dao = new MovieDaoImpl();
		List<Movie> list = dao.showMovieList();
		Gson gson = new Gson();
		String line = gson.toJson(list);	
		response.getWriter().print(line);
		
	}
	
	public static void main(String[] args) {
		MovieDao dao = new MovieDaoImpl();
		List<Movie> list = dao.showMovieList();
		Gson gson = new Gson();
		String line = gson.toJson(list);	
		System.out.println(line);
	}
	

}
